﻿<%@ WebHandler Language="C#" Class="zcc" %>

using System;
using System.Web;
using System.IO;
using System.Net;
using System.Text;


public class zcc : IHttpHandler {

    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";
        //  context.Response.Write("Hello World");
        string content = context.Request["content"];
        try
        {
                          
            string URL = "http://www.mqy.com.cn/api/action/errorword_check";
            HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(URL);
            Encoding encoding = Encoding.UTF8;
            // string param = HttpUtil.GetPostParams(context);
            Encoding GBKencoding = Encoding.GetEncoding("gbk");


            string param = "type=All&isHtmlFormat=1&isChecksensitive=1&key=1a263997-c680-4c50-a52e-af9ec27dbe44&content="+content;

            //encoding.GetBytes(postData);
            byte[] bs = Encoding.UTF8.GetBytes(param);
            string responseData = String.Empty;
            req.Method = "POST";
            req.ContentType = "application/x-www-form-urlencoded";
            req.ContentLength = bs.Length;
            req.ProtocolVersion = HttpVersion.Version10;
            using (Stream reqStream = req.GetRequestStream())
            {
                reqStream.Write(bs, 0, bs.Length);
                reqStream.Close();

            }
            using (HttpWebResponse response = (HttpWebResponse)req.GetResponse())
            {
                using (StreamReader reader = new StreamReader(response.GetResponseStream(), GBKencoding))
                {
                    responseData = reader.ReadToEnd().ToString();
                }
                context.Response.Write(responseData);
            }
        }
        catch (Exception e)
        {
            //LogWrite.WriteSysLog("Reservation_Location", e);
            //context.Response.Write(BackDataUtil.BackResult(110, "异常了", "0"));
            context.Response.Write(e);
        }


    }

    public bool IsReusable {
        get {
            return false;
        }
    }

}